
<template>
    <uni-data-select v-model="value" :localdata="range" @change="dataChange"></uni-data-select>
</template>
<script setup lang="ts">
import { useDistStore } from '@/stores/modules/dist';
import { ref, watch } from 'vue';
const value = ref("")
const range = ref([] as any)
const props = defineProps({
    modelValue: {
        type: String,
    },
    zdlb: {
        type: String,
        required: true
    }
})

watch(() => props.modelValue, (newValue) => {
    if (newValue) {
        value.value = newValue
    }
})

if (props.zdlb) {
    useDistStore().getDictList({ zdlb: props.zdlb }).then(result => {
        result.map(item => {
            range.value.push({ value: item.dm, text: item.mc })
        })
        if (props.modelValue) {
            value.value = props.modelValue
        }
    })
}



const emits = defineEmits(['update:modelValue']);
const dataChange = (e: any) => {
    emits('update:modelValue', e)
}

</script>
<style lang="scss" scoped>

</style>
